package com.example.controller;

import com.example.common.Result;
import com.example.entity.Admininfo;
import com.example.entity.TeacherInfo;
import com.example.service.AdminInfoService;
import com.example.service.TeacherInfoService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 涛某
 * @version 1.0
 * @date 2024/3/21 13:51
 */
@RestController
@RequestMapping("/teacherInfo")
public class TeacherInfoController {
    @Autowired
    private TeacherInfoService teacherInfoService;

    @PutMapping
    public Result update(@RequestBody TeacherInfo teacherInfo){
        teacherInfoService.update(teacherInfo);
        return Result.success();
    }
    @PostMapping()
    public Result add(@RequestBody TeacherInfo teacherInfo){

        teacherInfoService.add(teacherInfo);
        return Result.success();
    }
    @GetMapping
    public Result findAll(){
        List<TeacherInfo> list = teacherInfoService.findAll();
        return Result.success(list);
    }
    @DeleteMapping("/{id}")
    public Result deleteById(@PathVariable("id") Long id){

        teacherInfoService.deleteById(id);
        return Result.success();
    }
    @GetMapping("/page")
    public Result findPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize){

        PageInfo<TeacherInfo> info =  teacherInfoService.findPage(pageNum, pageSize);
        return Result.success(info);
    }
    @GetMapping("/page/{name}")
    public Result findPage(@RequestParam Integer pageNum, @RequestParam Integer pageSize,@PathVariable String name){

        PageInfo<TeacherInfo> info =  teacherInfoService.findPageName(pageNum, pageSize,name);
        return Result.success(info);
    }


}
